
import * as i18n from './LanguageData';

import { _decorator, Component, SpriteFrame, Sprite } from 'cc';
const { ccclass, property, executeInEditMode } = _decorator;

@ccclass('LocalizedText')
@executeInEditMode
export class LocalizedText extends Component {
    sprite: Sprite = null;

    onLoad() {
        if (!i18n.ready) {
            i18n.init('zh');
        }
        this.fetchRender();
    }

    fetchRender() {
        let sprite = this.getComponent('cc.Sprite') as Sprite;
        if (sprite) {
            this.sprite = sprite;
            this.updateSprite();
            return;
        }
    }

    updateSprite() {
        // 无法独立使用,需要继承各自的sprite来使用
    }

    lang() {
        return i18n._language;
    }
}